@extends('Home/Layout/baseusercenter')

@section('title', '我的地址')

{{--  首页主体  --}}
@section('main')

@section('title2', '我的地址')
            <div class="uc-content">
                <div class="uc-panel">
                    <div class="uc-bigtit">收货地址</div>
                    <div class="uc-panel-bd">

                            <div class="ui-msg-info ui-msg-block">最多可创建 5 个</div>

                            <div class="address-list">
                                <div class="col col-4">
                                    <a id='addaddress' class="item va-m-box ta-c add">
                                        <div class="add-new">
                                            <span class="ico"><i class="iconfont icon-tianjia"></i></span>
                                            <div class="label">添加收货地址</div>
                                        </div>
                                    </a>
                                </div>
                                @foreach ($useraddress as $val)
                                <div class="col col-4">
                                    <div class="item">
                                        <div class="action">
                                            <div class="fl"><a id='editAd' class="edit" href="{{url('/editAd', $val->id)}}">修改</a>
                                            <a id='rmAd' class="del" href="{{url('/deleteAd', $val->id)}}">删除</a></div>
                                        </div>
                                        <div class="info">
                                            <div class="info-item name ellipsis">{{$val->link_man}}</div>
                                            <div class="info-item address">{{$val->address}}</div>
                                            <div class="info-item tel ellipsis">{{$val->phone}}</div>
                                            <div class="glyphicon glyphicon-envelope">　{{$val->code}}</div>
                                            <div>{{($val->state == 1 )?'默认地址':''}}</div>
                                        </div>
                                    </div>
                                </div>
                                @endforeach
                            </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<div id="popupFormDiv" style="display:none;"></div>
@endsection

@section('footer-js')
    <script>
        $('#addaddress').on('click', function() {
             layer.open({
        title:'添加地址',
        type: 2,
        area: ['700px', '530px'],
        fix: false, //不固定
        maxmin: true,
        content: '{{url("/addAd")}}',
        success:function(layero,index){
        },
        end:function(){
            var handle_status = $("#handle_status").val();
            if ( handle_status == '1' ) {
                layer.msg('添加成功！',{
                    icon: 1,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                },function(){
                    history.go(0);
                });
            } else if ( handle_status == '2' ) {
                layer.msg('添加失败！',{
                    icon: 2,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                },function(){
                    history.go(0);
                });
            }
        }
    });
 });

    </script>
@endsection
